<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>电子教学日志管理</title>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.pagination.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/public.js"></script>
<script type="text/javascript" src="../../js/http.js"></script>
<script type="text/javascript" src="../../js/alert.js"></script>
<script type="text/javascript" src="../../js/jquery-ui/jquery-ui.min.js"></script>
<!-- <script src="../../../js/pdfobject.js" type="text/javascript"></script> -->
<!-- WdatePicker -->
<script type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js" ></script>
<link rel="stylesheet" type="text/css" href="../../js/jquery-ui/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.css">
</head>
<body>
	<object id="ocx" classid="CLSID:4E194A99-7F41-453E-914C-544BB186A59C"  codebase ="signocx.cab#version=1.0.0.3" width="100" height="50">
	</object>
	<div id="tabs" >
		<ul>
			<li><a href="#tabs-1">培训记录</a></li>
			<li><a href="#tabs-2">教学日志</a></li>
			<li><a href="#tabs-3">学习中视频资料</a></li>
			<li><a href="#tabs-4">阶段学习证书</a></li>
		</ul>
		<div id="tabs-1">
			<form id="stuLogForm">
				<table class="table table-bordered .table-condensed">
					<tbody>
						<tr style="text-align: center;">
							<td colspan="9">
								<h4>中华人民共和国机动车驾驶培训记录</h4>
							</td>
						</tr>
						<tr style="text-align: center;">
							<td style="width: 80px">姓名</td>
							<td>
								<label></label>
								<input type="hidden" name="updateJsStudent.name" />
							</td>
							<td>性别</td>
							<td style="width: 30px;">
								<label></label>
								<input type="hidden" name="updateJsStudent.sex" />
							</td>
							<td>身份证件号码</td>
							<td>
								<label></label>
								<input type="hidden" name="updateJsStudent.idcard" />
							</td>
							<td>入学时间</td>
							<td>
								<label></label>
								<input type="hidden" name="updateJsStudent.applydate" />
							</td>
							<td rowspan="3" width="100px;">(照片)</td>
						</tr>
						<tr style="text-align: center;">
							<td>家庭住址</td>
							<td colspan="4">
								<label></label>
								<input type="hidden" name="updateJsStudent.address" />
							</td>
							<td>联系方式</td>
							<td colspan="2">
								<label></label>
								<input type="hidden" name="updateJsStudent.phone" />
							</td>
						</tr>
						<tr style="text-align: center;">
							<td>申请车型</td>
							<td colspan="7">
								<!-- 可培训车型 vehicletype -->
								<label><input type="checkbox" id="vehicletype1" value="A1" />A1</label>
								<label><input type="checkbox" id="vehicletype2" value="A2" />A2</label>
								<label><input type="checkbox" id="vehicletype3" value="A3" />A3</label>
								<label><input type="checkbox" id="vehicletype4" value="B1" />B1</label>
								<label><input type="checkbox" id="vehicletype5" value="B2" />B2</label>
								<label><input type="checkbox" id="vehicletype7" value="C1" />C1</label>
								<label><input type="checkbox" id="vehicletype8" value="C2" />C2</label>
								<label><input type="checkbox" id="vehicletype9" value="C3" />C3</label>
								<label><input type="checkbox" id="vehicletype10" value="C4" />C4</label>
								<label><input type="checkbox" id="vehicletype11" value="C5" />C5</label>
								<label><input type="checkbox" id="vehicletype12" value="D" />D</label>
								<label><input type="checkbox" id="vehicletype13" value="E" />E</label>
								<label><input type="checkbox" id="vehicletype14" value="F" />F</label>
								<label><input type="checkbox" id="vehicletype15" value="M" />M</label>
								<label><input type="checkbox" id="vehicletype16" value="N" />N</label>
								<label><input type="checkbox" id="vehicletype17" value="P" />P</label>
								<input type="hidden" name="updateJsStudent.traintype" />
							</td>
						</tr>
						<tr style="text-align: center;">
							<td>科目名称</td>
							<td>培训学时</td>
							<td>学员签名</td>
							<td colspan="2">教员签名</td>
							<td colspan="2">培训单位意见</td>
							<td colspan="2">道路运管管理机构审核</td>
						</tr>
						<tr>
							<td style="text-align: center; height: 100px; line-height: 100px;">科目一</td>
							<td></td>
							<td><label style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label style="float: left; margin-top: 60px;">签名:</label>
							<label style="float: left; margin: 50px 0 0 50px;">(盖章)</label>
							<label style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label style="float: right; margin-top: 90px;">年月日</label></td>
						</tr>
						<tr>
							<td style="text-align: center; height: 100px; line-height: 100px;">科目二</td>
							<td></td>
							<td><label style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label
								style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label
								style="float: left; margin-top: 60px;">签名:</label> <label
								style="float: left; margin: 50px 0 0 50px;">(盖章)</label> <label
								style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label
								style="float: right; margin-top: 90px;">年月日</label></td>
						</tr>
						<tr>
							<td
								style="text-align: center; height: 100px; line-height: 100px;">科目三</td>
							<td></td>
							<td><label style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label
								style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label
								style="float: left; margin-top: 60px;">签名:</label> <label
								style="float: left; margin: 50px 0 0 50px;">(盖章)</label> <label
								style="float: right; margin-top: 90px;">年月日</label></td>
							<td colspan="2"><label
								style="float: right; margin-top: 90px;">年月日</label></td>
						</tr>
						<tr>
							<td colspan="9">
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:1、培训记录一式三份，在完成培训和考试所有程序后，培训单位
								、道路运管管理机构、公安交通管理部门车辆管理所各一份。
								2、在预约科目一、科目二考试时,公安交通管理部门车辆管理所查验培训记录后，应将培训记录退还驾校。在预约科目三考试时，公安交通管理部门车辆管理所查验培训记录后，应收存归档。
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>

		<div id="tabs-2">
			<form id="stuLogDetailForm">
				<table class="table table-bordered .table-condensed">
					<tbody>
						<tr>
							<td>姓名:</td>
							<td name="name" colspan="2"></td>
							<td>学驾类别:</td>
							<td name="traintype" colspan="2"></td>
						</tr>
						<tr>
							<td>所属驾校:</td>
							<td name="school" colspan="2"></td>
							<td>学驾阶段:</td>
							<td colspan="2"></td>
						</tr>
						<tr>
							<td>报名时间:</td>
							<td name="applydate" colspan="2"></td>
							<td>状态:</td>
							<td colspan="2"></td>
						</tr>
						<tr>
							<td>证件号:</td>
							<td name="idcard" colspan="2"></td>
							<td></td>
							<td colspan="2"></td>
						</tr>
						<tr>
							<td>第一部分学时:</td>
							<td name="keMu1"></td>
							<td>
								<a href="javascript:beiAnStageTrainningTime(1);" class="btn btn-success">备案科目一学时</a>
								<a href="javascript:queryStageTrainningTime(1);" class="btn btn-success">备案结果查询</a>
							</td>
							<td>第二部分学时:</td>
							<td name="keMu2"></td>
							<td>
								<a href="javascript:beiAnStageTrainningTime(2);" class="btn btn-success">备案科目二学时</a>
								<a href="javascript:queryStageTrainningTime(2);" class="btn btn-success">备案结果查询</a>
							</td>
						</tr>
						<tr>
							<td>第三部分学时:</td>
							<td name="keMu3"></td>
							<td>
								<a href="javascript:beiAnStageTrainningTime(3);" class="btn btn-success">备案科目三学时</a>
								<a href="javascript:queryStageTrainningTime(3);" class="btn btn-success">备案结果查询</a>
							</td>
							<td>培训总里程:</td>
							<td colspan="2"></td>
						</tr>
						<tr>
							<td>第四部分学时:</td>
							<td name="keMu4"></td>
							<td>
								<a href="javascript:beiAnStageTrainningTime(4);" class="btn btn-success">备案科目四学时</a>
								<a href="javascript:queryStageTrainningTime(4);" class="btn btn-success">备案结果查询</a>
							</td>
							<td>总学时:</td>
							<td name="sumXueShi" colspan="2"></td>
						</tr>
					</tbody>
				</table>
			</form>
			<div >
				<span>查询</span>
					<select id="query" style="width: 90px;">
						<option value="请选择">-请选择-</option>
						<option value="name">姓名</option>
						<option value="idcard">身份证号</option>
						<option value="phone">手机号</option>
					</select>
				<input type="text" id="keywords" placeholder="Key" style="width:120px;"/>
				<span>学习日期</span>
				<input type="text" id="studyDate"  onClick="WdatePicker();" style="width:120px;"/>
				
				<button type="button" onclick="searchPage(1,10);" class="btn btn-success">查询</button>
			</div>
			<table class="table table-bordered .table-condensed" id="datas">
				<tr>
					<td style="text-align:center" name="ids">ID</td>
					<td style="text-align:center" name="keMu">培训部分</td>
					<td style="text-align:center" name="studyContent">教学科目</td>
					<td style="text-align:center" name="mileageSum">培训里程</td>
					<td style="text-align:center" name="xueShi">学习学时</td>
					<td style="text-align:center" name="state">达标状态</td>
					<td style="text-align:center" name="flowStr">备案流程</td>
					<td style="text-align:center" name="id" other="stuStudyLog2">操作</td>
				</tr>
			</table>
			
			<div class="pager"></div>
		</div>
			
			
		<div id="tabs-3">
			<table class="table table-bordered .table-condensed" id="data">
				<tr>
					<td name="ids">ID</td>
					<td name="order">所属订单</td>
					<td name="student">所属学员</td>
					<td name="startTime">视频拍摄时间</td>
					<td name="endTime">视频结束时间</td>
					<td name="id" other="stuStudyLog3">操作</td>
				</tr>
			</table>
		</div>
		
		<div id="tabs-4">
			<div id="jdPdf" style="height:450px;width:100%;">  
			</div> 
		</div>
	</div>


   <!-- 查看教学日志明细 -->
   <div id="studyLoginDetailDiv" style="display: none;" title="教学日志明细">
   	<iframe src="" style="width:100%;height: 100%"  frameborder="no" marginwidth="0" marginheight="0" allowtransparency="yes"></iframe>
   </div>
   
   <div style="display:none;">
   	<form action="" name="sendForm" id="sendForm">
   		<input type="hidden" name="keMuTemp"/>
   		<input type="hidden" name="suIdTemp"/>
   		<input type="hidden" name="esignatureTemp"/>
   	</form>
   	
	<table border="0">	
	  <tr>
	    <td nowrap>原文</td>  
		<td width="10"><input type="text"  id="data" value="" ></td>  
	  </tr>
	  <tr>
	    <td nowrap>签名值</td>  
		<td width="10"><input type="text"  id="signature" value="" ></td>  
	  </tr>  
	  <tr>
	    <td nowrap>证书</td>  
		<td width="10"><input type="text"  id="cert" value="" ></td>  
	  </tr>    
	  <tr>
	    <td width="10"><input type="button" value="读取签章" onclick="readseal()"></td>
	  </tr>
	  <tr>
	    <td width="10"><input type="button" value="数字签名" onclick="sign()"></td>
	  </tr>
	  <tr>
		<td width="10"><input type="button" value="验证签名" onclick="verify()"></td>
	  </tr>
	  <tr>
		<td width="10"><input type="button" value="获取证书信息" onclick="getCertInfo()">
	  </tr>
	</table>
	<textarea id="txt"></textarea>
   </div>
    
    
</body>

<script type="text/javascript">
	var href = location.href.split("=");
	var stuId = href[1];
	lookLog(stuId);
	$("#tabs").tabs();
	function readseal(){
		var obj = window.document.getElementById("ocx"); 
		var seal;
		var sealInfo = obj.ReadSeal();
		var sealInfoList = sealInfo.toArray();
		return sealInfoList;
	}
	
	function sign(data){
		var obj = window.document.getElementById("ocx"); 
		var signInfo = obj.sign(data);
		var signInfoList = signInfo.toArray();
		return signInfoList;
	}
	
	function verify(){
		var obj = window.document.getElementById( "ocx"); 
		var data = window.document.getElementById("data").value;
		var signature = window.document.getElementById("signature").value;
		var cert = window.document.getElementById("cert").value;
		var ok = obj.verify(data, signature, cert);
	}
	
	function getCertInfo(){
		var obj = window.document.getElementById( "txt");
		var obj = window.document.getElementById( "ocx"); 
		var cert = window.document.getElementById("cert").value;
		var certInfo = obj.GetCertInfo(cert);
		var certInfoList = certInfo.toArray();
		return certInfoList;
	}


	//查看培训记录
	function lookLog(id) {
		/* new PDFObject({   
		url: pickerProjectAdd + "pdf/10793163.pdf",   //pdf文件路径
		pdfOpenParams: {   
		     view: 'Fit',   
		     scrollbars: '0',   
		     toolbar: '0',   
		     statusbar: '0',   
		     navpanes: '0' }  
		 }).embed('jdPdf');   //显示Pdf内容的Div　　ID
		  */
		$("#tabs").find("input[id^='vehicletype']").each(function() {
			var check = $(this).prop("checked");
			if (check == true) {
				$(this).parent().click();
			}
		});
		$.ajax({
			url : "../../student/get.ao",
			type : 'POST',
			data : {
				"id" : id
			},
			cache : false,
			dataType : "json",
			success : function(data) {
				$("#stuLogForm").find("input").each(function() {
					var a = $(this).attr("name");//获得Input文本框的name值，这个ID值 对应着Json数据中对象的值（PS：一个是大写一个小写 ） 
					if (a == null || typeof (a) == "undefined") {
						return;
					}
					a = a.substring(16, a.length + 1);
					a = a.toLowerCase();
					if (data["result"][a] == null || typeof (data["result"][a]) == "undefined") {
						return;
					}

					if (a == "sex") {
						$(this).parent().find("label").html(data["result"][a] == 1 ? "男" : "女");
					} else if (a == "traintype") {
						$("input[id^='vehicletype']").each(function() {
							var vv = $(this).val();
							if (vv == data["result"][a]) {
								$(this).parent().click();
							}
						});
					} else {
						$(this).parent().find("label").html(data["result"][a]);
					}
				});

				$("#stuLogDetailForm").find("td").each(function() {
					var a = $(this).attr("name");//获得Input文本框的name值，这个ID值 对应着Json数据中对象的值（PS：一个是大写一个小写 ） 
					if (a == null || typeof (a) == "undefined") {
						return;
					}
					if (a == "sex") {
						$(this).html(data["result"][a] == 1 ? "男" : "女");
					}else {
						$(this).html(data["result"][a]);
					}
				});
			}
		});

		//查找教学日志
		searchXueshiPage(1, 10);
		
		//查询学习过程中的视频资料 
		searchStudyVideo(1,1000);
		
	}
	
	function searchStudyVideo(pageNo,pageSize){
		 $.ajax({
			url : "../../trainVideo/getTrainVideoByStu.ao",
			type : 'POST',
			data : {
				'pageNo' : pageNo,
				'pageSize' : pageSize,
				'stuId' : stuId
			},
			beforeSend : ajaxstar,
			complete : ajaxend,
			cache : false,
			dataType : "json",
			success : function(data) {
				if (data["state"] == "success") {
					insertTr(data, 0);
				}
			}
		});
	}

	//查看教学日志
	function searchXueshiPage(pageNo, pageSize) {
		var part = $("#part").val();
		var studyDate = $("#studyDate").val(); 
		$.ajax({
			url : "../../studyLog/getStuStudyLog.ao",
			type : 'POST',
			data : {
				'pageNo' : pageNo,
				'pageSize' : pageSize,
				'id' : stuId,
				'part' : part,
				'studyDate' : studyDate
			},
			beforeSend : ajaxstar,
			complete : ajaxend,
			cache : false,
			dataType : "json",
			success : function(data) {
				if (data["state"] == "success") {
					insertTr(data, 0);
					$("#stuLogDetailForm").find("td").each(function() {
						var a = $(this).attr("name");//获得Input文本框的name值，这个ID值 对应着Json数据中对象的值（PS：一个是大写一个小写 ） 
						if (a == null || typeof (a) == "undefined") {
							return;
						}
						if(a == "keMu1" || a == "keMu2" || a == "keMu3" || a == "keMu4" || a == "sumXueShi"){
							$(this).html(data["keMuXueShi"][a]["result"]);
						}else {
							$(this).html(data["result"][a]);
						}
					});
					
				} else {
					alert(data["result"]);
				}
			}
		}); 
	}

	//查看
	function look(id) {
		$("#studyLoginDetailDiv").find("iframe").attr("src","../studyLog/info.html?id="+id);//代表以时间作为文件夹
		$("#studyLoginDetailDiv").dialog({
			title : "明细",
			resizable : false,
			width : 750,
			height : 700,
			resizable : true,
			modal : false,
			buttons : {
				"关闭" : function() {
					$(this).dialog("close");
				}
			}
		});
	}
	
	//学习过程中视频资料备案
	function videoBeiAn(id){
		$.ajax({
			url : "../../putOnRecord/addTrainVideoPutOnRecord.ao",
			type : 'POST',
			data : {
				"id" : id
			},
			cache : false,
			dataType : "json",
			success : function(data) {
				if (data["state"] == "success") {
					alert(data["result"]);
				} else {
					alert(data["result"]);
				}
			}
		})
	}
	
	
	//备案教学日志
	function beiAn(id){
		$.ajax({
			url : "../../putOnRecord/addStudyLogPutOnRecord.ao",
			type : 'POST',
			data : {
				"id" : id
			},
			cache : false,
			dataType : "json",
			success : function(data) {
				if (data["state"] == "success") {
					alert(data["result"]);
				} else {
					alert(data["result"]);
				}
			}
		})
	}
	
	//阶段培训记录上报备案
	function beiAnStageTrainningTime(keMu){
		$.ajax({
			url : "../../putOnRecord/stageTrainningTime2.ao",
			type : 'POST',
			data : {
				"keMu" : keMu,
				"stuId" : stuId
			},
			cache : false,
			dataType : "json",
			success : function(data) {
				if (data["state"] == "success") {
					
					 var seal, signature, signerCert, sn;
				     var sealInfo = readseal();
				     if (sealInfo[0]) seal = sealInfo[0];
				     var signInfo = sign(data["result"]);
				     signature = signInfo[0];
				     signerCert = signInfo[1];
				     var certInfo = getCertInfo(signerCert);
				     sn = certInfo[0];
				     
				     var obj = window.document.getElementById("ocx"); 
				 	var signInfo = obj.sign(data);
				 	var signInfoList = signInfo.toArray();
				  	
					$("input[name='keMuTemp']").val(keMu);
					$("input[name='suIdTemp']").val(stuId);
					$("input[name='esignatureTemp']").val(signature);

					 $.ajax({
						url : host + "/putOnRecord/stageTrainningTime.do",
						type : 'POST',
						data : $("#sendForm").serialize(),
						cache : false,
						dataType : "json",
						success : function(data) {
							if (data["state"] == "success") {
								alert(data["result"]);
							} else {
								alert(data["result"]);
							}
						}
					});
				} else {
					alert(data["result"]);
				}
			}
		})
	}
	
	//阶段培训记录上报备案结果查询
	function queryStageTrainningTime(keMu){
		$.ajax({
			url : "../../putOnRecord/stageTrainningTimeReview.ao",
			type : 'POST',
			data : {
				"keMu" : keMu,
				"stuId" : stuId
			},
			cache : false,
			dataType : "json",
			success : function(data) {
				if (data["state"] == "success") {
					alert(data["result"]);
				} else {
					alert(data["result"]);
				}
			}
		})
	}
	
	//学员结业信息上传
	function uploadCcInfo(id){
		$.ajax({
			url : "../../putOnRecord/graduation2.ao",
			type : 'POST',
			data : {
				"stuId" : id
			},
			cache : false,
			dataType : "json",
			success : function(data) {
				if (data["state"] == "success") {
					 var seal, signature, signerCert, sn;
				     var sealInfo = readseal();
				     if (sealInfo[0]) seal = sealInfo[0];
				     var signInfo = sign(data["result"]);
				     signature = signInfo[0];
				     signerCert = signInfo[1];
				     var certInfo = getCertInfo(signerCert);
				     sn = certInfo[0];
				     
				     var obj = window.document.getElementById("ocx"); 
				 	var signInfo = obj.sign(data);
				 	var signInfoList = signInfo.toArray();
				     
					$("input[name='suIdTemp']").val(id);
					$("input[name='esignatureTemp']").val(signature);

					 $.ajax({
						url : host + "/putOnRecord/graduation.do",
						type : 'POST',
						data : $("#sendForm").serialize(),
						cache : false,
						dataType : "json",
						success : function(data) {
							if (data["state"] == "success") {
								alert(data["result"]);
							} else {
								alert(data["result"]);
							}
						}
					}) 
				} else {
					alert(data["result"]);
				}
			}
		});
	}
</script>
</html>